﻿using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Iesi.Collections.Generic;

namespace Apodidae.Domain.Entity
{
    /// <summary>
    /// 用户信息
    /// </summary>
    public class UserInfo : BaseObject<string>
    {
        public UserInfo()
        {
            TeachedClasses = new HashedSet<ClassInfo>();
        }


        /// <summary>
        /// 用户的用户名
        /// </summary>
        public virtual string LoginId { get; set; } 
        /// <summary>
        /// 用户的密码
        /// </summary>
        public virtual string Pwd { get; set; }
        /// <summary>
        /// 用户标记识码
        /// </summary>
        public virtual string UserNum { get; set; } 
        /// <summary>
        /// 真实姓名
        /// </summary>
        public virtual string RealName { get; set; } 
        /// <summary>
        /// 用户昵称
        /// </summary>
        public virtual string NickName { get; set; } 
        /// <summary>
        /// 用户注册类型
        /// </summary>
        public virtual UserType ? UserType { get; set; }
        /// <summary>
        /// 性别
        /// </summary>
        public virtual bool IsMale { get; set; }
        /// <summary>
        /// 手机
        /// </summary>
        public virtual string Mobile { get; set; }
        /// <summary>
        /// QQ
        /// </summary>
        public virtual string QQ { get; set; }
        /// <summary>
        /// Email
        /// </summary>
        public virtual string Email { get; set; }
        /// <summary>
        /// 最后一次登陆时间
        /// </summary>
        public virtual DateTime ? LastLoginDate { get; set; }
        /// <summary>
        /// 最后一次挂起时间
        /// </summary>
        public virtual DateTime? LastSuspentTime { get; set; }

        /// <summary>
        /// 多对一: 多个学生，可以在一个班级
        /// </summary>
        public virtual ClassInfo ClassInfo { get; set; }
        /// <summary>
        /// 多对一: 多个学生，可以在一个组
        /// </summary>
        public virtual GroupInfo GroupInfo { get; set; }

        /// <summary>
        /// 一对多：一个老师可以有多个班级
        /// </summary>
        public virtual ISet<ClassInfo> TeachedClasses { get; set; }
        public void AddTeachClasses(ClassInfo classInfo)
        {
            classInfo.Teacher = this;
            this.TeachedClasses.Add(classInfo);
        }
        public void RemoveTeachClasses(ClassInfo classInfo)
        {
            this.TeachedClasses.Remove(classInfo);
        }

        /// <summary>
        /// 小组长所在的组
        /// </summary>
        public virtual GroupInfo MasteredGroup { get; set; }
    }

    /// <summary>
    /// 用户类型
    /// </summary>
    public enum  UserType
    {
        General = 0,
        Admin = 1,
        SuperAdmin =2
    }

    /// <summary>
    /// 用户登陆结果
    /// </summary>
    public enum AutherResult
    {
        /// <summary>
        /// 用户不存在
        /// </summary>
        UserNotFind = 0,
        /// <summary>
        /// 密码不正确
        /// </summary>
        ErrPWD = 1,
        /// <summary>
        /// 成功
        /// </summary>
        Succeed = 2,
        /// <summary>
        /// 冻结
        /// </summary>
        Suspent = 3,
        /// <summary>
        /// 已过期
        /// </summary>
        OutOfDate = 4
    }
}
